const app = getApp();
import { getIdSwiper } from "../../../request/api.js";
var WxParse = require('../../../common/wxParse/wxParse.js');

Page({

    /**
     * 页面的初始数据
     */
    data: {
        path: null,
        postId: 0,
        contentDetailed: '',
        ifFresh: false, // 从圈子来
        freshPost: ''
    },
    
    // 获取内容
    getPost() {
        let postId = this.data.postId
        let data = { postId }
        getIdSwiper(res => {
            if (res.statusCode == 200) {
                let content = res.data.content
                WxParse.wxParse("html_content", "html", content, this)
                this.setData({ contentDetailed: res.data })
            }
        }, data);
    },

    // 圈子连接内容
    freshCon(options) {
        if(options.freshPost && options.freshPost.length > 0) {
            let freshPost_parse = JSON.parse(options.freshPost)
            if (freshPost_parse.linkType == 1) {
                let content_1 = freshPost_parse.content
                WxParse.wxParse("html_content", "html", content_1, this)
                this.setData({ freshPost: freshPost_parse.content })
            }
            this.setData({ freshPost: freshPost_parse, ifFresh: true });
        } else {
            this.setData({ postId: options.itemId });
            this.getPost()
        }
    },


    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this.setData({ lang: app.globalData.lang, navTitle: "promote", navigation: true })
        this.freshCon(options)
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})